home *** CD-ROM | disk | FTP | other *** search
/ Programming an RTS Game with Direct3D / Programming an RTS Game with Direct3D.iso / Examples / Chapter 14 / Example 14.1 / mapObject.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-06-30  |  1.8 KB  |  55 lines

  1. #ifndef _MAP_OBJECT_
  2. #define _MAP_OBJECT_
  3.  
  4. #include "terrain.h"
  5. #include "intpoint.h"
  6. #include "mouse.h"
  7. #include "effect.h"
  8.  
  9. //Global Functions
  10. void LoadMapObjectResources(IDirect3DDevice9* m_pDevice);
  11. void UnloadMapObjectResources();
  12. INTPOINT GetScreenPos(D3DXVECTOR3 pos, IDirect3DDevice9* m_pDevice);
  13.  
  14. class GROUPAI;
  15.  
  16. class MAPOBJECT
  17. {
  18.     public:
  19.         //Functions
  20.         MAPOBJECT();                            //Set all variables to 0
  21.         RECT GetMapRect(int border);            //Get map rectangle + border
  22.         INTPOINT GetAttackPos(INTPOINT from);    //Get position to attack this mapobject from
  23.         void PaintSelected(float time);            //Paint m_selected
  24.         void RenderSightMesh();                    //Render sightTexture & mesh for this mapobject
  25.         std::vector<MAPOBJECT*> GetTargetsWithinRange(int theRange);    //Returns any enemy targets within m_range
  26.         MAPOBJECT* BestTargetToAttack(std::vector<MAPOBJECT*> &enemies);        
  27.  
  28.         //Virtual Functions
  29.         virtual void Render() = 0;
  30.         virtual void Update(float deltaTime) = 0;
  31.         virtual BBOX GetBoundingBox() = 0;        //Bounding box in world space
  32.         virtual D3DXMATRIX GetWorldMatrix() = 0;
  33.         virtual bool isDead() = 0;
  34.         virtual void Damage(int dmg, MAPOBJECT* attacker) = 0;
  35.  
  36.         //Variables
  37.         TERRAIN *m_pTerrain;            //Used for unit pathfinding, building placement etc
  38.         int m_hp, m_hpMax;                //Health and max health
  39.         int m_range;                    //Attack m_range
  40.         int m_damage;
  41.         INTPOINT m_mappos, m_mapsize;    //Location and m_mapsize
  42.         float m_sightRadius;
  43.         int m_team, m_type;
  44.         bool m_selected, m_dead;
  45.         std::string m_name;
  46.         MAPOBJECT *m_pTarget;            //Used for targeting both units and buildings
  47.         D3DXVECTOR3 m_position;        //Actual world position
  48.         IDirect3DDevice9* m_pDevice;
  49.  
  50.         bool m_isBuilding;            //Used when casting pointers...
  51.         bool m_visible;                //Used to cull with FogOfWar
  52.         GROUPAI *m_pGroup;
  53. };
  54.  
  55. #endif